<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!-- 用户输入内容 -->
        <input type="text" @keydown.enter="btn">
        <!-- <button @click="btn">确定</button> -->

        <!-- 未完成 -->
        <h1>未完成事件</h1>
        <div class="not-finished" v-for="(item,index) in notFinishedArr">
            <div :key="item.id">
                <input type="checkbox" @change="c(item,index)" :checked="item.isChecked">
                <span>{{item.thing}}</span>
                <button @click="notFinishedArr.splice(index,1)">删除</button>
            </div>
        </div>

        <!-- 已经完成 -->
        <h1>已经完成事件</h1>
        <div class="finished" v-for="(item,index) in finishedArr">
            <div :key="item.id">
                <input type="checkbox" @change="c(item,index)" :checked="item.isChecked">
                <span>{{item.thing}}</span>
                <button @click="finishedArr.splice(index,1)">删除</button>
            </div>
        </div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        let vm = new Vue({
            el: "#app",
            data: {
                // 未完成的事情
                notFinishedArr: [{
                    id: 1,
                    thing: "敲代码",
                    isChecked: false
                }, {
                    id: 2,
                    thing: "整理笔记",
                    isChecked: false
                }],


                //  已完成的事情
                finishedArr: [{
                    id: 3,
                    thing: "脑袋放空, 进入提前放假模式",
                    isChecked: true
                }],
                comment_text:"",
                id:3
            },
            methods: {
                btn(){
                    this.id++
                    this.notFinishedArr.push({id:this.id,thing:event.target.value,isChecked:false})
                    console.log(this.notFinishedArr);
                    event.target.value = ""
                },
                c(item,index){
                    item.isChecked = !item.isChecked
                    console.log(item.isChecked);
                    if(item.isChecked){
                        this.notFinishedArr.splice(index,1)
                        this.finishedArr.push(item)
                    }else{
                        this.finishedArr.splice(index,1)
                        this.notFinishedArr.push(item)
                    }
                }
            }
        })
    </script>
</body>

</html>